<template>
  <el-dialog
      title="校区审核"
      :visible.sync="auditDialog.visible"
      width="30%">
      <el-form>
        <el-form-item label="审核学校">
          <el-tag>{{auditDialog.name}}</el-tag>
        </el-form-item>
        <el-form-item label="学校地址">
          <el-tag>{{auditDialog.location}}</el-tag>
        </el-form-item>
        <el-form-item label="状态">
          <el-radio-group v-model="auditDialog.operaType">
            <el-radio :label="item.value" v-for="item in auditDialog.auditData" :key="item.value">{{item.label}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="备注">
          <el-input
          type="textarea"
          :autosize="{ minRows: 6, maxRows: 10}"
          placeholder="请输入内容"
          show-word-limit
          maxlength="50"
          v-model="auditDialog.reason">
        </el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="auditDialog.visible = false">取 消</el-button>
        <el-button type="primary" @click="auditComfig">确 定</el-button>
      </span>
    </el-dialog>
</template>

<script>
import {
  Vue,
  ref,
  toRefs,
  shallowRef,
  reactive,
  watch,
  watchEffect,
  getCurrentInstance,
  computed,
  defineComponent,
  nextTick,
  inject,
  onMounted,
  onUnmounted
} from 'vue'
import { Message,MessageBox } from 'element-ui'
import store from '@/store'
import {setSchoolAudit} from '@/api/school/school_api.js'
export default {
  name: 'andit',
  setup(props, { emit }) {
   // const emits = defineEmits(['onOk'])
    const Interface = reactive({
      auditClick(row){
        query.auditDialog.id = row.id
        query.auditDialog.operaType = ''
        query.auditDialog.reason = ''
        query.auditDialog.name = row.name
        query.auditDialog.location = row.location
        query.auditDialog.visible = true
      },
      async auditComfig(){
        let params = {}
        params.id = query.auditDialog.id
        if(!query.auditDialog.operaType){
          Message.error('请选择审核状态')
          return;
        }
        if(!query.auditDialog.reason){
          Message.error('请选择审核意见')
          return;
        }
        params.operaType = query.auditDialog.operaType
        params.reason = query.auditDialog.reason
       const {code} = await setSchoolAudit(params)
        if(code === 0){
          Message.success('操作成功')
          query.auditDialog.visible = false
          emit('onOk')
        }
      },
    })
    const query = reactive({
      auditDialog:{
        operaType:'',
        visible:false,
        reason:'',
        id:'',
        name:'',
        location:'',
        auditData:[{value:1,label:'审核通过'},{value:2,label:'审核不通过'}]
      }
    })
    return {
      ...toRefs(query),
      ...toRefs(Interface)
    }
  }
}
</script>